#include<bits/stdc++.h>
using namespace std;

int main(){
    vector<int> arr(100);
    int i = 0;
    while(1){
        cin>>arr[i];
        if(arr[i] == 0) break;
        i++;
    }

    int sz = arr.size();
    int cnt = -1;
    for(int i = 0;i<sz;i++){
        cnt++;
        //cout<<cnt<<" ";
       // cout<<arr[i]<<" ";
        if(arr[i] == 0) break;

    }
    for(int i = cnt-1;i>=0;i--){
        cout<<arr[i]<<" ";
    }



    return 0;
}